<?php
session_start();

// Parametros de configuracion
include_once('configuracion.php');

// Funciones de acceso a BD
include_once('interface_db.php');

//if (isset($_SESSION['paramdb']) && isset($_SESSION['USUARIO'])){
if (isset($_SESSION['paramdb']) && isset($_POST['idPais'])!=''){

	$idPais = $_POST['idPais'];	

?>
		<div class="portlet-header fixed">
        	<img src="images/icons/feed.gif" width="16" height="16" alt="" /> Lista de Departamentos
        </div>
		<div class="portlet-content nopadding">
        <form action="" method="post">
          <table width="100%" cellpadding="0" cellspacing="0" id="box-table-a" summary="">
            <thead>	
              <tr>
                <th width="20" scope="col"></th>
				<th width="30%" scope="col">Pais</th>
                <th width="30%" scope="col">Departamento</th>
                <th width="10%" scope="col">Codigo</th>
                <th width="10%" scope="col">Estatus</th>
                <th width="10%" scope="col">Editar</th>
				<th width="10%" scope="col">Eliminar</th>
              </tr>
            </thead>
            <tbody>
			<?php
				$objdb = new DBSql($_SESSION['paramdb']);
				$objdb -> db_connect();
				if ($objdb -> is_connection()){
					$rsDepartamentos = $objdb -> sqlListaDepartamentosXPais($idPais);
			
					if (mysql_num_rows($rsDepartamentos)!=0){
			
						while ($row = mysql_fetch_array($rsDepartamentos)){
						
							$idDepartamento = $row["idDepartamento"];
							$pais = $row["pais"];
							$descripcion = $row["Descripcion"];
							$codigo = $row["Codigo"];
							$estatus = $row["Estatus"];
							$estado = "INACTIVO";
							
							if($estatus==1){
								$estado = 'ACTIVO';
							}
			?>
							<tr>
								<td width="20"></td>
								<td><?= $pais; ?></td>
								<td><?= $descripcion; ?></td>
								<td><?= $codigo; ?></td>
								<td><?= $estado; ?></td>
								<td><a href="#" onClick="Operacion_Departamento('1','<?=$idDepartamento ?>','<?=$descripcion ?>')" class="edit_icon" title="Editar"></a></td>
								<td><a href="#" onClick="Operacion_Departamento('2','<?=$idDepartamento ?>','<?=$descripcion ?>')" class="delete_icon" title="Eliminar"></a></td>
							</tr>
			 <?php
						}
						mysql_free_result($rsDepartamentos);
					}
				}
			 
			 ?>
			 <!--
              <tr class="footer">
                <td colspan="6">								
					<a href="#" class="button_grey_round" onClick="Operacion_Departamento('0','agregar')"><span>Agregar</span></a>
				</td>
                <td align="right">&nbsp;</td>
			  </tr>
			  -->
            </tbody>
          </table>
        </form>
		</div>
		
<?php		

}else{
	header("Location: error.php");
  	exit();
}

?>	

<script type="text/javascript">


	
</script>	